package cn.itcast.mq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * TODO
 *
 * @Author mr.wu
 * @Date 2025/1/5 11:02
 */
@Configuration
public class RabbitMQConfig {
    /**
     * 创声明队列名
     * @return
     */
    @Bean
    public Queue simplequeue() {
        return new Queue("simple-queue");
    }


    /**
     * 创声明队列名
     * @return
     */
    @Bean
    public Queue workqueue() {
        return new Queue("work-queue");
    }

    /**
     * 广播模型-声明队列1
     * @return
     */
    @Bean
    public Queue fanoutQueue1() {
        return new Queue("fanout-queue1");
    }

    /**
     * 广播模型-声明队列2
     * @return
     */
    @Bean
    public Queue fanoutQueue2() {
        return new Queue("fanout-queue2");
    }

    /**
     * 广播模型-声明交换机
     * @return
     */
    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("fanout-exchange");
    }

    /**
     * 声明队列1绑定交换机
     * @return
     */
    @Bean
    public Binding binding1() {
        return BindingBuilder.bind(fanoutQueue1()).to(fanoutExchange());
    }

    /**
     * 声明队列2绑定交换机
     * @return
     */
    @Bean
    public Binding binding2() {
        return BindingBuilder.bind(fanoutQueue2()).to(fanoutExchange());
    }


}
